﻿/*----------------------------------------------------------------
//  <copyright file="IRoleUserStore.cs" company="MicroCloud@151504200868">
//      Copyright © 2020-2024 MicroCloud Corporation, All rights reserved.
//  </copyright>
//  <site>https://gitee.com/chenmm123/microclouds</site>
//  <last-editor>cmm</last-editor>
//  <last-date>2022-12-23 12:56</last-date>
//----------------------------------------------------------------*/

namespace MicroCloud.Identity
{
    #region "角色用户仓储接口"
    /// <summary>
    /// 角色用户仓储接口
    /// </summary>
    /// <typeparam name="TRole">角色实体类型</typeparam>
    public interface IRoleUserStore<TRole> : IQueryableRoleStore<TRole>, IDisposable
        where TRole : class
    {
        #region "方法"
        #region "将指定的角色添加到用户"
        /// <summary>
        /// 将指定的角色添加到用户
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="userId">用户编号</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns><see cref="Task" />表示一个异步的<see cref="OperationResult" /></returns>
        Task<OperationResult> AddToUserAsync(TRole role, string userId, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "将指定的角色添加到用户集合"
        /// <summary>
        /// 将指定的角色添加到用户集合
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="userIds">用户编号集合</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns><see cref="Task" />表示一个异步的<see cref="OperationResult" /></returns>
        Task<OperationResult> AddToUsersAsync(TRole role, string[] userIds, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "从用户中删除指定的角色"
        /// <summary>
        /// 从用户中删除指定的角色
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="userId">用户编号</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns><see cref="Task" />表示一个异步的<see cref="OperationResult" /></returns>
        Task<OperationResult> RemoveFromUserAsync(TRole role, string userId, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "从用户集合中删除指定的角色"
        /// <summary>
        /// 从用户集合中删除指定的角色
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="userIds">用户编号集合</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns><see cref="Task" />表示一个异步的<see cref="OperationResult" /></returns>
        Task<OperationResult> RemoveFromUsersAsync(TRole role, string[] userIds, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "获取设置当前角色的用户编号集合"
        /// <summary>
        /// 获取设置当前角色的用户编号集合
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns>包含用户编号集合的<see cref="Task" />结果</returns>
        Task<IList<string>> GetUsersAsync(TRole role, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "返回一个标志，指示指定的角色是否为给定用户的成员"
        /// <summary>
        /// 返回一个标志，指示指定的角色是否为给定用户的成员
        /// </summary>
        /// <param name="role">角色实体</param>
        /// <param name="userId">用户编号</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns>包含一个布尔值的<see cref="Task" />结果</returns>
        Task<bool> IsInUserAsync(TRole role, string userId, CancellationToken cancellationToken = new CancellationToken());
        #endregion
        #region "返回作为用户成员的角色列表"
        /// <summary>
        /// 返回作为用户成员的角色列表
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="cancellationToken">用于传播应取消操作的通知</param>
        /// <returns>包含角色集合的<see cref="Task" />结果</returns>
        Task<IList<TRole>> GetRolesInUserAsync(string userId, CancellationToken cancellationToken = new CancellationToken());
        #endregion

        #endregion

    }
    #endregion

}
